Skip to content

Expose swift debug payload#283

Merged
Takaros999 merged 24 commits into
mainfrom
expose-swift-debug-payload
Jun 19, 2026
Merged

Expose swift debug payload#283
Takaros999 merged 24 commits into
mainfrom
expose-swift-debug-payload

Conversation

@kchaw2005

@kchaw2005 kchaw2005 commented Jun 16, 2026

Copy link
Copy Markdown
Contributor

Summary

We wanted to expose raw payload fields to Swift developers of IDKit. Moreover, we wanted to expose the fields as native swift structs to catch possible errors at compile time.

Fix

Added UniFFI records in bridge.rs that map from the existing build_request_payload wire JSON via parse helpers, plus new bridge_debug_payload methods on IDKitBuilder. Swift now exposes bridgeDebugPayload on IDKit and IDKitBuilder so devs can dot into fields like proofRequest.proofRequests instead of parsing dictionaries. Kept the JSON-returning helpers as a fallback for logging or if you need the raw wire string. Updated the swift test to assert on typed fields instead of JSONSerialization.


Note

Medium Risk
Touches bridge payload construction and FFI surface for proof-request fields, but the change is additive (debug/fixture APIs) and normal encrypted bridge flows still serialize the same wire JSON.

Overview
Adds a typed, network-free path to inspect the plaintext bridge request that IDKit would send, aimed at test fixtures and contract debugging on Swift and Kotlin (mirrored on both).

In Rust, payload construction now returns a BridgeRequestPayload struct internally, with build_request_payload_json kept for wire serialization; UniFFI records/objects (BridgeRequestPayloadWrapper, nested proof/credential/constraint wrappers) map from that payload. IDKitBuilder gains bridge_request_payload / JSON helpers for constraints and presets without opening a bridge connection.

Swift and Kotlin expose createBridgePayloadFromPresets and createBridgePayloadFromConstraints, typealiases for the wrapper types, and credentialIdentifiers helpers. Tests now assert on typed fields (identity check, passport-or-mnc constraints) instead of parsing JSON. WASM nativePayload call sites switch to the JSON builder; Swift packaging adjusts XCFramework header layout.

Reviewed by Cursor Bugbot for commit dc064a7. Bugbot is set up for automated code reviews on this repo. Configure here.

@vercel

vercel Bot commented Jun 16, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
idkit-js-example Ready Ready Preview, Comment Jun 18, 2026 11:00pm

Request Review

Comment thread scripts/package-swift.sh

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR exposes a “plaintext bridge payload” JSON builder for native SDKs (Swift and Kotlin) via UniFFI/Rust, enabling integrators to inspect and assert the bridge payload contract before encryption/upload—aligned with the bridgeDebugPayload* naming direction used in JS.

Changes:

  • Rust/UniFFI: Add IDKitBuilder.bridge_debug_payload_json* APIs that serialize the existing request payload builder output (without creating a bridge request and without a timestamp).
  • Swift & Kotlin: Add builder wrapper methods to surface the new UniFFI APIs (bridgeDebugPayloadJSON / bridgeDebugPayloadJson, plus preset variants).
  • Tests: Add Swift and Kotlin tests asserting the identity-check preset payload includes key contract fields and omits timestamp.

Reviewed changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated no comments.

Show a summary per file
File Description
swift/Tests/IDKitTests/IDKitTests.swift Adds a Swift test validating the identity-check plaintext bridge payload JSON contract.
swift/Sources/IDKit/IDKit.swift Exposes new Swift IDKitBuilder methods to fetch plaintext bridge payload JSON (constraints + preset).
scripts/package-swift.sh Adjusts Swift XCFramework header/modulemap staging to use ios_build/Headers/ root.
rust/core/src/bridge.rs Implements UniFFI-exposed Rust methods to build/serialize plaintext bridge payload JSON without creating a request.
kotlin/bindings/src/test/kotlin/com/worldcoin/idkit/IDKitTests.kt Adds a Kotlin test validating the identity-check plaintext bridge payload JSON contract.
kotlin/bindings/src/main/kotlin/com/worldcoin/idkit/IdKit.kt Exposes new Kotlin IDKitBuilder methods for plaintext bridge payload JSON (constraints + preset).

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

…wift gets typed structs instead of raw json

added BridgeDebugPayload (and related records) in bridge.rs with parsing from the
existing build_request_payload wire json, plus bridge_debug_payload ffi methods on
IDKitBuilder. swift now exposes bridgeDebugPayload on IDKit/IDKitBuilder for
property access in tests and app code. kept the json-returning helpers as a
fallback for logging or if you need the raw wire string. updated swift tests to
assert on typed fields instead of JSONSerialization.

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes using default effort and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, have a team admin enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 7beed69. Configure here.

Comment thread rust/core/src/bridge.rs Outdated
@Takaros999

Copy link
Copy Markdown
Contributor

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: d6bd916fc5

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread rust/core/src/bridge.rs
/// wrong, or serialization fails.
pub fn build_request_payload(
/// Returns an error if constraints are invalid or the signature/nonce format is wrong.
fn build_request_payload(

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Keep build_request_payload public

When Rust consumers build the plaintext bridge JSON directly through the public idkit_core::bridge::build_request_payload(...) helper, this change removes that symbol from the public bridge module and changes its return type to the private wire struct. Even though in-repo call sites were moved to build_request_payload_json, downstream integrations that use the existing helper will fail on upgrade; keep a public shim with the old Result<serde_json::Value> signature or deprecate it instead of making the rename source-breaking.

Useful? React with 👍 / 👎.

@Takaros999 Takaros999 merged commit 876f1fe into main Jun 19, 2026
27 of 28 checks passed
@Takaros999 Takaros999 deleted the expose-swift-debug-payload branch June 19, 2026 01:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants